package com.grsu.phonestation.web.info;

import com.grsu.phonestation.domain.FreeService;
import com.grsu.phonestation.domain.InternetService;
import com.grsu.phonestation.domain.PhoneService;
import com.grsu.phonestation.domain.Service;

/**
 * 
 * @author Ilona
 *
 *Class that stores information about the service, her price, type and is subscribe current client for her
 *
 */
public class InfoService {

	private Service service;
	private boolean canSubscribe;
	private String price;
	private String typeService;

	public String getTypeService() {
		return typeService;
	}

	public void setTypeService(String typeService) {
		this.typeService = typeService;
	}

	public InfoService(Service service) {
		this.service = service;
		this.canSubscribe = false;
		if (service instanceof FreeService) {
			price = " --- ";
		} else if (service instanceof PhoneService) {
			price = ((PhoneService) service).getPrice() + " $/min";
		} else if (service instanceof InternetService) {
			price = ((InternetService) service).getPrice() + " $/mb";
		}
		typeService = service.getDiscriminatorValue();
	}
/**
 * 
 * @param canSubscribe - is subscribe current client for service
 */
	public InfoService(Service service, boolean canSubscribe) {
		this.service = service;
		this.canSubscribe = canSubscribe;
		if (service instanceof FreeService) {
			price = " --- ";
		} else if (service instanceof PhoneService) {
			price = ((PhoneService) service).getPrice() + " $/min";
		} else if (service instanceof InternetService) {
			price = ((InternetService) service).getPrice() + " $/mb";
		}
		typeService = service.getDiscriminatorValue();
	}

	public String getPrice() {
		return price;
	}

	public Service getService() {
		return service;
	}

	public boolean isCanSubscribe() {
		return canSubscribe;
	}

	public void setCanSubscribe(boolean canSubscribe) {
		this.canSubscribe = canSubscribe;
	}

	public void setPrice(String price) {
		this.price = price;
	}

	public void setService(Service service) {
		this.service = service;
	}

}
